package com.leetcode.LC;

import java.util.Arrays;

public class LC66 {
    public int[] plusOne(int[] digits) {
        int[] ints = new int[digits.length+1];
        for (int i = digits.length-1; i >=0; i--) {
            if (digits[i]==9){
                digits[i]=0;
            }else {
                digits[i]++;
                return digits;
            }
        }
        Arrays.fill(ints,0);
        ints[0]=1;

        return ints;
    }

    public static void main(String[] args) {
        for (int i : new LC66().plusOne(new int[]{9,9,9})) {
            System.out.print(i+",");
        }
    }
}
